package com.zhgxi.security.entity;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Proxy;

import com.zhgxi.core.orm.hibernate.BaseEntity;

@Entity
@Table(name = "roles")
@Proxy(lazy = false)  
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Roles extends BaseEntity {

	private String name;
	private boolean enable;

	@ManyToMany(targetEntity = Resources.class, fetch = FetchType.EAGER)  
    @JoinTable(name = "roles_resources", joinColumns = @JoinColumn(name = "rid"), inverseJoinColumns = @JoinColumn(name = "reid"))  
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) 
	private Set<Resources> resources;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public Set<Resources> getResources() {
		return resources;
	}

	public void setResources(Set<Resources> resources) {
		this.resources = resources;
	}

}
